import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.mysql.cj.jdbc.Driver;

public class MybatisPlusGenerator {

    public static void main(String[] args) {
        new AutoGenerator()
                .setDataSource(dataSourceConfig())
                .setPackageInfo(packageConfig())
                .setStrategy(strategyConfig())
                .setGlobalConfig(globalConfig())
                .execute();
    }

    private static GlobalConfig globalConfig() {
        return new GlobalConfig()
                .setFileOverride(true)
                .setSwagger2(false)
                .setAuthor("dzh")
                .setOpen(false)
                .setOutputDir("src/main/java");
    }

    private static StrategyConfig strategyConfig() {
        return new StrategyConfig()
                .setEntityLombokModel(true)
                .setEntityTableFieldAnnotationEnable(false)
                .setSuperEntityClass("com.glodon.coral.data.jpa2.entity.BaseEntity")
                .setNaming(NamingStrategy.underline_to_camel)
                .setEntitySerialVersionUID(false)
                .setSuperEntityColumns("createTime", "id", "updateTime")
                .setInclude("finance_repayment_plan");
    }

    private static PackageConfig packageConfig() {
        return new PackageConfig()
                .setParent("com.glodon.dpm.finance.service");
    }

    private static DataSourceConfig dataSourceConfig() {
        return new DataSourceConfig()
                .setUsername("newuser")
                .setPassword("newuser")
                .setDbType(DbType.MYSQL)
                .setDriverName(Driver.class.getName())
                .setUrl("jdbc:mysql://10.0.164.57:30175/dpm-test");
    }
}
